// pages/menu/menu.js
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        active: 0,
        tabData: [{
                title: '推荐',
                normal: '../../images/icons_09.gif',
                active: '../../images/icons_21.gif'
            },
            {
                title: '拿铁',
                normal: '../../images/icons_05.gif',
                active: '../../images/icons_19.gif'
            },
            {
                title: '咖啡',
                normal: '../../images/icons_03.gif',
                active: '../../images/icons_18.gif'
            },
            {
                title: '瑞纳冰',
                normal: '../../images/icons_07.gif',
                active: '../../images/icons_20.gif'
            },
        ],
        recomData: null,
        latteData: null,
        coffeeData: null,
        riceData: null
    },
    pushSearch() {
        wx.navigateTo({
            url: '/pages/search/search',
        })
    },
    onChange(event) {
        this.setData({
            active: event.detail
        });
    },
    onLoad() {
        // 推荐
        wx.request({
            url: 'http://www.kangliuyong.com:10002/typeProducts',
            method: 'GET',
            data: {
                appkey: app.globalData.appkey,
                key: 'isHot',
                value: 1
            },
            success: (res) => {
                console.log(res);
                this.setData({
                    recomData: res.data.result
                })
            }
        })
        // 拿铁
        wx.request({
            url: 'http://www.kangliuyong.com:10002/typeProducts',
            method: 'GET',
            data: {
                appkey: app.globalData.appkey,
                key: 'type',
                value: 'latte'
            },
            success: (res) => {
                console.log(res);
                this.setData({
                    latteData: res.data.result
                })
            }
        })
        // 咖啡
        wx.request({
            url: 'http://www.kangliuyong.com:10002/typeProducts',
            method: 'GET',
            data: {
                appkey: app.globalData.appkey,
                key: 'type',
                value: 'coffee'
            },
            success: (res) => {
                console.log(res);
                this.setData({
                    coffeeData: res.data.result
                })
            }
        })
        // 瑞纳冰
        wx.request({
            url: 'http://www.kangliuyong.com:10002/typeProducts',
            method: 'GET',
            data: {
                appkey: app.globalData.appkey,
                key: 'type',
                value: 'rena_ice'
            },
            success: (res) => {
                console.log(res);
                this.setData({
                    riceData: res.data.result
                })
            }
        })
    }

})